<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - load_image.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2011  Davis E. King (davis@dlib.net), Nils Labugt
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#ifndef</font> DLIB_LOAd_IMAGE_H__
<font color='#0000FF'>#define</font> DLIB_LOAd_IMAGE_H__

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='load_image_abstract.h.html'>load_image_abstract.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../string.h.html'>../string.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='png_loader.h.html'>png_loader.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='jpeg_loader.h.html'>jpeg_loader.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='image_loader.h.html'>image_loader.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> image_type<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='load_image'></a>load_image</b> <font face='Lucida Console'>(</font>
        image_type<font color='#5555FF'>&amp;</font> image,
        <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> file_name
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>const</font> std::string extension <font color='#5555FF'>=</font> <font color='#BB00BB'>tolower</font><font face='Lucida Console'>(</font><font color='#BB00BB'>right_substr</font><font face='Lucida Console'>(</font>file_name,"<font color='#CC0000'>.</font>"<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>extension <font color='#5555FF'>=</font><font color='#5555FF'>=</font> "<font color='#CC0000'>bmp</font>"<font face='Lucida Console'>)</font>
            <font color='#BB00BB'>load_bmp</font><font face='Lucida Console'>(</font>image, file_name<font face='Lucida Console'>)</font>;
<font color='#0000FF'>#ifdef</font> DLIB_PNG_SUPPORT
        <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>extension <font color='#5555FF'>=</font><font color='#5555FF'>=</font> "<font color='#CC0000'>png</font>"<font face='Lucida Console'>)</font>
            <font color='#BB00BB'>load_png</font><font face='Lucida Console'>(</font>image, file_name<font face='Lucida Console'>)</font>;
<font color='#0000FF'>#endif</font>
<font color='#0000FF'>#ifdef</font> DLIB_JPEG_SUPPORT
        <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>extension <font color='#5555FF'>=</font><font color='#5555FF'>=</font> "<font color='#CC0000'>jpeg</font>" <font color='#5555FF'>|</font><font color='#5555FF'>|</font> extension <font color='#5555FF'>=</font><font color='#5555FF'>=</font> "<font color='#CC0000'>jpg</font>"<font face='Lucida Console'>)</font>
            <font color='#BB00BB'>load_jpeg</font><font face='Lucida Console'>(</font>image, file_name<font face='Lucida Console'>)</font>;
<font color='#0000FF'>#endif</font>
        <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>extension <font color='#5555FF'>=</font><font color='#5555FF'>=</font> "<font color='#CC0000'>dng</font>"<font face='Lucida Console'>)</font>
            <font color='#BB00BB'>load_dng</font><font face='Lucida Console'>(</font>image, file_name<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>else</font>
        <b>{</b>
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>extension <font color='#5555FF'>=</font><font color='#5555FF'>=</font> "<font color='#CC0000'>jpeg</font>" <font color='#5555FF'>|</font><font color='#5555FF'>|</font> extension <font color='#5555FF'>=</font><font color='#5555FF'>=</font> "<font color='#CC0000'>jpg</font>"<font face='Lucida Console'>)</font>
                <font color='#0000FF'>throw</font> <font color='#BB00BB'>image_load_error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>DLIB_JPEG_SUPPORT not #defined: Unable to load image in file </font>" <font color='#5555FF'>+</font> file_name<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>extension <font color='#5555FF'>=</font><font color='#5555FF'>=</font> "<font color='#CC0000'>png</font>"<font face='Lucida Console'>)</font>
                <font color='#0000FF'>throw</font> <font color='#BB00BB'>image_load_error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>DLIB_PNG_SUPPORT not #defined: Unable to load image in file </font>" <font color='#5555FF'>+</font> file_name<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>else</font>
                <font color='#0000FF'>throw</font> <font color='#BB00BB'>image_load_error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Unknown file extension: Unable to load image in file </font>" <font color='#5555FF'>+</font> file_name<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>

<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_LOAd_IMAGE_H__ 
</font>

</pre></body></html>